package com.appos.service;

import com.appos.domain.AppWorkSheetGroupRelation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AppWorkSheetGroupRelationService {
    private static final Logger logger = LoggerFactory.getLogger(AppWorkSheetGroupRelationService.class);

    @Autowired
    private MongoTemplate mongoTemplate;

    /**
     * 保存对象
     * @param appWorkSheetGroupRelation
     * @return
     */
    public int save(AppWorkSheetGroupRelation appWorkSheetGroupRelation) {
        mongoTemplate.save(appWorkSheetGroupRelation);
        return 1;
    }

    /***
     * 根据appId查询
     * @param appId
     * @return
     */
    public List<AppWorkSheetGroupRelation> getAppWorkSheetGroupRelation(String appId) {
        Query query = new Query(Criteria.where("appId").is(appId));
        return mongoTemplate.find(query, AppWorkSheetGroupRelation.class);
    }
}
